package com.vue.mapper;

import com.github.pagehelper.Page;
import com.vue.annotation.AutoFill;
import com.vue.dto.CoursePageQueryDTO;
import com.vue.dto.StudentPageQueryDTO;
import com.vue.dto.TeacherPageQueryDTO;
import com.vue.entity.Course;
import com.vue.entity.Student;
import com.vue.entity.Teacher;
import com.vue.enumeration.OperationType;
import com.vue.vo.TeacherRegisterVO;
import com.vue.vo.UserInfoVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface TeacherMapper {
    /**
     * 动态获取教师数据
     * @param userInfoVO
     * @return
     */
    Teacher getTeacher(UserInfoVO userInfoVO);

    /**
     * 教师分页查询
     * @param teacherPageQueryDTO
     * @return
     */
    Page<Teacher> teacherPageQuery(TeacherPageQueryDTO teacherPageQueryDTO);

    /**
     * 根据id删除教师
     * @param id
     */
    @Delete("delete from teacher where id=#{id}")
    void deleteById(Long id);

    /**
     * 课程分页查询
     * @param coursePageQueryDTO
     * @return
     */
    Page<Course> coursePageQuery(CoursePageQueryDTO coursePageQueryDTO);

    /**
     * 新增教师
     * @param teacher
     */
    @Insert("insert into teacher (username, name, avatar, phone, email, gender, course_id, create_time, update_time) " +
            "values (#{username},#{name},#{avatar},#{phone},#{email},#{gender},#{courseId},#{createTime},#{updateTime})")
    @AutoFill(OperationType.INSERT)
    void insert(Teacher teacher);

    /**
     * 修改教师
     * @param teacher
     */
    @AutoFill(OperationType.UPDATE)
    void update(Teacher teacher);
}
